import JDBCUtils.JDBCUtils;
import org.junit.jupiter.api.Test;


import java.util.Scanner;

/**
 *练习题1：从控制台向数据库的表customers中插入一条数据，表结构如下：
 */
public class ExerTest01 {

    @Test
    public  void testInsert()  {
        try {
            Scanner scanner=new Scanner(System.in);
            System.out.println("请输入用户名:");
            String name=scanner.next();
            System.out.println("请输入邮箱:");
            String email=scanner.next();
            System.out.println("请输入生日:");
            String birthday=scanner.next();
            String  sql="insert into customers(name,email,birth)values(?,?,?)";
            boolean update = JDBCUtils.update(sql, name, email, birthday);
            if(update){
                System.out.println("插入成功");
            }else{
                System.out.println("插入失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
